﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace HZ.BidSystem.DAL
{
    class DAL_Util
    {
        public static Assembly GetCallingAssembly()
        {
            return System.Reflection.Assembly.GetCallingAssembly();
        }

        /// <summary>
        /// 获取调用公钥
        /// </summary>
        /// <returns></returns>
        public static string GetPublicKeyToken()
        {
            string fullname = GetCallingAssembly().FullName;
            var strarray = fullname.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            if (strarray.Length != 4)
            {
                return "";
            }
            var str = strarray[3];
            var array2 = fullname.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
            if (array2.Length == 2)
            {
                return array2[1];
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 获取调用程序集
        /// </summary>
        /// <returns></returns>
        public static string GetAssemblyName()
        {
            string fullname = GetCallingAssembly().FullName;
            var strarray = fullname.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            if (strarray.Length != 4)
            {
                return "";
            }
            else
            {
                return strarray[0].Trim();
            }

        }
    }
}
